﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>    


		<head>
		<script type="text/javascript" src="<c:url value='/easyui/datagrid-detailview.js'/>"></script>
		<SCRIPT language=JAVASCRIPT src='<c:url value="/js/grid.js"/>'></SCRIPT>
		<script type="text/javascript">
			$(function(){
				  init();
			});


			
			function init(){
				$('#t-dg').datagrid({
				loadMsg:'',
				view:detailview,
				rowStyler:function(index,row){  		            
			        if(row.timeout <= 0){               
			        	return 'background-color:${cfgs["expbgcolor"]};color:${cfgs["expfgcolor"]};font-weight:bold;';     
		            }   
		        },  
				detailFormatter:function(index,row){
				  var content = '';
          
          
          
          if (row.sysinfo_type)  {
   content += '<span style="color:blue;font-weight:700">公告类型：</span></br>';
   content += '<div style="padding:5px">'+ row.sysinfo_type.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.unitname)  {
   content += '<span style="color:blue;font-weight:700">单位名称：</span></br>';
   content += '<div style="padding:5px">'+ row.unitname.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.editdate)  {
   content += '<span style="color:blue;font-weight:700">录入时间：</span></br>';
   content += '<div style="padding:5px">'+ row.editdate.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.context)  {
   content += '<span style="color:blue;font-weight:700">公告内容：</span></br>';
   content += '<div style="padding:5px">'+ row.context.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.valid_time_hist)  {
   content += '<span style="color:blue;font-weight:700">失效时间：</span></br>';
   content += '<div style="padding:5px">'+ formatvalid_time_hist(row.valid_time_hist)+'</div>';
}
if (row.oper)  {
   content += '<span style="color:blue;font-weight:700">操作人员：</span></br>';
   content += '<div style="padding:5px">'+ row.oper.replace(/\r\n/gi,'<br/>')+'</div>';
}
   content += '<span style="color:blue;font-weight:700">审核：</span></br>';
   content += '<div style="padding:5px">'+ formatpassflag(row.passflag)+'</div>';

<c:if test="${passmode == 'true'}">	
   content += '<span style="color:blue;font-weight:700">置顶：</span></br>';
   content += '<div style="padding:5px">'+ formattotop(row.totop)+'</div>';
if (row.totopdate)  {
   content += '<span style="color:blue;font-weight:700">置顶到期时间：</span></br>';
   content += '<div style="padding:5px">'+ row.totopdate.replace(/\r\n/gi,'<br/>')+'</div>';
}
   content += '<span style="color:blue;font-weight:700">滚动：</span></br>';
   content += '<div style="padding:5px">'+ formattoroll(row.toroll)+'</div>';
if (row.torolldate)  {
   content += '<span style="color:blue;font-weight:700">滚动到期时间：</span></br>';
   content += '<div style="padding:5px">'+ row.torolldate.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.rollmsg)  {
   content += '<span style="color:blue;font-weight:700">滚动简要信息：</span></br>';
   content += '<div style="padding:5px">'+ row.rollmsg.replace(/\r\n/gi,'<br/>')+'</div>';
}
</c:if>
           
					return '<div style="padding:5px">' + content + '</div>';
				}
				
			});
				
			}
			
			
			
			
			
			var actionUrl;
			function newItem(){
				$('#dlg').dialog('setTitle', '新增公告信息').dialog('open');
				$('#myform').form('clear');
				actionUrl = '<c:url value="/myinfo/Sysinfo/saveSysinfo"/>';
			}
			
			function editItem(){
				var t = $('#t-dg');
				if (isSingleSelect(t)){
				var row = t.datagrid('getSelected');
				if (row){
					$('#myform').form('load', row);
					$('#dlg').dialog('setTitle', '修改公告信息').dialog('open');
					actionUrl = '<c:url value="/myinfo/Sysinfo/updateSysinfo"/>?id=' + row.id;
				}
				}
			}
			
			
			
			
			function deleteItem(){
				var t = $('#t-dg');
				if (isSingleSelect(t)){
				var row = t.datagrid('getSelected');
				if (row){
					$.messager.confirm('删除确认', '是否确定要删除选择公告信息?', function(r){
						if (r){
					$.ajax({
						url:'<c:url value="/myinfo/Sysinfo/destroySysinfo"/>?id=' + row.id,
						type:'post',
						success:function(){		
							$('#t-dg').datagrid('reload');
						}
					});
						}
						});
				}
				}
			}
			
			function saveItem(){
				$('#myform').form('submit', {
					url:actionUrl,
					onSubmit:function(){
						return $('#myform').form('validate');
					},
					success:function(data){
						var data = eval('('+data+')');
						if (data.success){
							$('#dlg').dialog('close');
							$('#t-dg').datagrid('reload');
						} else {
							$.messager.show({
								title:'保存失败',
								msg:'<pre>'+data.msg+'</pre>'
							});
						}
					}
				});
			}
			
			function batpassItem(){
				var t = $('#t-dg');
				var rows = t.datagrid('getSelections');
				var ids = [];			
				if (rows){
					for(var i = 0, row; row = rows[i]; i++){
						ids.push(row.id);
					}
					
					$.messager.confirm('批量通过确认', '是否确定要批量通过选择公告信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/myinfo/sysinfo/batpassSysinfo"/>?ids=' + ids,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
			}
			
			function passItem(){				
				var t = $('#t-dg');
				if (isSingleSelect(t)){
				var row = t.datagrid('getSelected');
				if (row){
					
					$.messager.confirm('通过确认', '是否确定要通过选择公告信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/myinfo/sysinfo/passSysinfo"/>?id=' + row.id,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
				}
			}
			
			function batunpassItem(){
				var t = $('#t-dg');
				var rows = t.datagrid('getSelections');
				var ids = [];			
				if (rows){
					for(var i = 0, row; row = rows[i]; i++){
						ids.push(row.id);
					}
					
					$.messager.confirm('批量通过确认', '是否确定要批量不通过选择公告信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/myinfo/sysinfo/batunpassSysinfo"/>?ids=' + ids,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
			}
			
			function unpassItem(){
				var t = $('#t-dg');
				if (isSingleSelect(t)){
				var row = t.datagrid('getSelected');
				if (row){
					
					$.messager.confirm('不通过确认', '是否确定要不通过选择公告信息?', function(r){
							if (r){
					$.ajax({
						url:'<c:url value="/myinfo/sysinfo/unpassSysinfo"/>?id=' + row.id,
						type:'post',
						success:function(){
							$('#t-dg').datagrid('reload');
						}
					});
				}});
					
				}
				}
			}
			
			
			function formattoroll(value){
				if (value == "1") 
					return "滚动";
				if (value == "0") 
					return "不滚动";

				}
			
			function formattotop(value){
				if (value == "1") 
					return "置顶";
				if (value == "0") 
					return "不置顶";

				}
			
			function formatpassflag(value){
				if (value == "-1") 
					return "<font color=red>未通过</font>";
				if (value == "0") 
					return "<font color=blue>通过</font>";

				}
			
			function formatvalid_time_hist(value){
				switch(value){
				case '-1':
					return  "永不过期";
				case '3':
					return "三天";
				case '7':
					return "一周";
				case '31':
					return "一月";
				case '91':
					return "三月";
				case '182':
					return "半年";
				case '365':
					return "一年";
				}

				}
			
			function doQuery(value){
				$('#t-dg').datagrid('load', {
					q: value
				});
			}
			
		</script>
	</head>
	<body>
		<div class="easyui-layout" fit="true">
			<div region="north" border="false" style="height:40px;padding:5px;overflow:hidden;">
			<div style="padding-top:3px;float:left">
			<input class="easyui-searchbox" prompt="按公告类型|公告内容进行查询" searcher="doQuery" style="width:300px"></input>
  		</div>
		<div style="float:left">
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newItem()">新增公告</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editItem()">修改公告</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteItem()">删除公告</a>
		</div>	
			<c:if test="${passmode == 'true'}">	
			<div style="float:right">		
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="batpassItem()">批量通过审核</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="batunpassItem()">批量取消通过</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="passItem()">通过审核</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="unpassItem()">取消通过</a>
			</div>
			</c:if>	
		
	</div>
			
			
			<div region="center" border="true">
	      <table id="t-dg" style="display:none;"
						url="<c:url value='/myinfo/Sysinfo/getSysinfoItems'/>"
						rownumbers="true" pagination="true"
						border="false" fit="true" fitColumns="true">
					<thead>
						<tr>
						<th field="ck" checkbox="true"></th>
							<th field="sysinfo_type" width="100" sortable="true">公告类型</th>
<th field="unitname" width="100" sortable="true">单位名称</th>
<th field="editdate" width="100" sortable="true">录入时间</th>
<th field="context" width="100" sortable="false">公告内容</th>
<th field="valid_time_hist" width="100" sortable="false" formatter="formatvalid_time_hist">失效时间</th>
<th field="oper" width="100" sortable="false">操作人员</th>
<th field="passflag" width="100" sortable="false" formatter="formatpassflag">审核</th>

						</tr>
					</thead>
				</table>			
			</div>
		</div>
		
		
		
			<div id="dlg" maximized="true"
				class="easyui-dialog" closed="true" modal="true" buttons="#dlg-buttons">
			<div style="padding:10px">
				<div style="float:left">
					<form id="myform" method="post" style="margin:0;padding:0">

<table>
<tr>
<td style="width:120px">公告类型</td>
<td>
<select id="sysinfo_type" name="sysinfo_type" 
	data-options="required:true,editable:true" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="通告">通告</option>
		<option value="广播">广播</option>
		<option value="合作">合作</option>
		<option value="求助">求助</option>
		<option value="意见">意见</option>
		<option value="维护">维护</option>
		<option value="急急急">急急急</option>		
		<option value="楼盘推荐">楼盘推荐</option>	
		<option value="求租求购">求租求购</option>			
</select></td>

<td style="width:120px">失效时间</td>
<td>
<select id="valid_time_hist" name="valid_time_hist" 
	data-options="required:true,editable:true" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="-1">永不过期</option>	
		<option value="3">三天</option>	
		<option value="7">一周</option>
		<option value="31">一月</option>
		<option value="91">三月</option>
		<option value="182">半年</option>	
		<option value="365">一年</option>		
</select></td>
</tr>														
<c:if test="${passmode == 'true'}">	
<tr>
<td style="width:120px">置顶</td>
<td>
<select id="totop" name="totop" 
	data-options="required:true,editable:true" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="0">不置顶</option>
		<option value="1">置顶</option>		
</select></td>
<td style="width:120px">置顶到期时间</td>
<td><input id="totopdate" name="totopdate" class="easyui-datetimebox" style="width:250px" data-options="required:true,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:120px">滚动</td>
<td>
<select id="toroll" name="toroll" 
	data-options="required:true,editable:true" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="0">不滚动</option>
		<option value="1">滚动</option>		
</select></td>
<td style="width:120px">滚动到期时间</td>
<td><input id="torolldate" name="torolldate" class="easyui-datetimebox" style="width:250px" data-options="required:true,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:120px">滚动简要描述</td>
<td colspan="3"><input type="text" class="easyui-validatebox e-input" id="rollmsg" name="rollmsg" style="width:630px;" data-options="required:true,editable:true" ></input></td>
</tr>	
</c:if> 
<tr>
<td colspan=4 style="width:120px">公告内容</td></tr>
<tr>
<td colspan="4"><textarea type="text" class="easyui-validatebox e-input" id="context" name="context" style="width:750px;height:250px" data-options="required:false,editable:true" ></textarea>

</td>
</tr>	
<tr>
</table>
						
					</form>
				</div>			
				<div style="clear:both"></div>
			</div>
			<div id="dlg-buttons" style="text-align:center;">
				<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="saveItem()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
			</div>
		</div>
		
		
		
		
	</body>
